<%@include file="ValidarSession.jsp"%>
<%@include file="cabecera.jsp"%>

<script language="javascript">
function addRowToTable(tbl2)
{
  var tbl = document.getElementById(tbl2);
  var lastRow = tbl.rows.length;
  // if there's no header row in the table, then iteration = lastRow + 1
  var iteration = lastRow - 1;
  var row = tbl.insertRow(lastRow);

  // left cell
  var cellLeft = row.insertCell(0);
  var textNode = document.createTextNode(iteration);
  cellLeft.appendChild(textNode);

  // right cell
  var cellRight = row.insertCell(1);
  var el = document.createElement('input');
  el.type = 'text';
  el.name = 'txtRow' + iteration;
  el.id = 'txtRow' + iteration;
  el.size = 114;

    // right cell
  var cellRight2 = row.insertCell(2);
  var el2 = document.createElement('input');
  el2.type = 'text';
  el2.name = 'txtRow' + (iteration + 1);
  el2.id = 'txtRow' + (iteration + 1);
  el2.size = 10;

 var cellRight3 = row.insertCell(3);
  var el3 = document.createElement('input');
  el3.type = 'text';
  el3.name = 'txtRow' + (iteration + 2);
  el3.id = 'txtRow' + (iteration + 2);
  el3.size = 10;


  cellRight.appendChild(el);
  cellRight2.appendChild(el2);
  cellRight3.appendChild(el3);

  // select cell

 var cellSel = row.insertCell(4);
var sel = document.createElement('input');
 sel.type = 'checkbox';
sel.name = 'checkbox' + (iteration + 2);
 sel.id = 'checkbox' + (iteration + 2);

  cellSel.appendChild(sel);

}
function keyPressTest(e, obj)
{
  var validateChkb = document.getElementById('chkValidateOnKeyPress');
  if (validateChkb.checked) {
    var displayObj = document.getElementById('spanOutput');
    var key;
    if(window.event) {
      key = window.event.keyCode;
    }
    else if(e.which) {
      key = e.which;
    }
    var objId;
    if (obj != null) {
      objId = obj.id;
    } else {
      objId = this.id;
    }
    displayObj.innerHTML = objId + ' : ' + String.fromCharCode(key);
  }
}
function removeRowFromTable(tblk)
{
  var tbl = document.getElementById(tblk);
  var lastRow = tbl.rows.length;
  if (lastRow > 3) tbl.deleteRow(lastRow - 1);
}
function openInNewWindow(frm)
{
  // open a blank window
  var aWindow = window.open('', 'TableAddRowNewWindow',
   'scrollbars=yes,menubar=yes,resizable=yes,toolbar=no,width=400,height=400');

  // set the target to the blank window
  frm.target = 'TableAddRowNewWindow';

  // submit
  frm.submit();
}
function validateRow(frm)
{
  var chkb = document.getElementById('chkValidate');
  if (chkb.checked) {
    var tbl = document.getElementById('tblSample');
    var lastRow = tbl.rows.length - 1;
    var i;
    for (i=1; i<=lastRow; i++) {
      var aRow = document.getElementById('txtRow' + i);
      if (aRow.value.length <= 0) {
        alert('Row ' + i + ' is empty');
        return;
      }
    }
  }
  openInNewWindow(frm);
}
</script>

<table class="subtitulo" align="center" width="960" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">

    <form action="" method="" >

<p>
<input type="button" value="Agregar Actividad" onclick="addRowToTable('tblSample');" />
<input type="button" value="Remover Ultimo" onclick="removeRowFromTable('tblSample');" />
<input type="button" value="Remover Seleccionados" onclick="removeRowFromTable('tblSample');" />
</p>
<table border="1" id="tblSample" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" >
  <tr>
    <th colspan="5">Actividades</th>
  </tr>
  <tr>
    <th >Item</th>
    <th >Nombre</th>
    <th >H-H</th>
    <th >Tiempo</th>
    <th >&nbsp;</th>
    </tr>
  <tr>
    <td>1</td>
    <td><input type="text" name="txtRow1"
     id="txtRow1" size="114" /></td>
    <td><input name="txtRow2" type="text" id="txtRow2" size="10" /></td>
    <td><input name="txtRow3" type="text" id="txtRow3" size="10" /></td>
    <td align="center"> <input type="checkbox" name="checkbox" id="checkbox" /></td>
    </tr>
</table>




<p>
  <input type="button" value="Agregar Repuestos, Materiales o Equipos" onclick="addRowToTable('tblSample2');" />
  <input type="button" value="Remover" onclick="removeRowFromTable('tblSample2');" />
  <input type="button" value="Remover Seleccionados" onclick="removeRowFromTable('tblSample2');" />
</p>
<table border="1" id="tblSample2" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">
  <tr>
    <th colspan="5">Repuestos,Materiales y Equipos de Servicio</th>
  </tr>
  <tr>
    <th>Item</th>
    <th>Nombre</th>
    <th>Cantidad</th>
    <th>Costo</th>
    <th>&nbsp;</th>
  </tr>
  <tr>
    <td>1</td>
    <td><input type="text" name="txtRow4"
     id="txtRow4" size="114" /></td>
    <td><input name="txtRow4" type="text" id="txtRow5" size="10" /></td>
    <td><input name="txtRow6" type="text" id="txtRow6" size="10" /></td>
    <td align="center" ><input type="checkbox" name="checkbox2" id="checkbox2" /></td>
  </tr>
</table>
<p>
  <input type="button" value="Agregar Personal" onclick="addRowToTable('tblSample3');" />
  <input type="button" value="Remover Personal" onclick="removeRowFromTable('tblSample3');" />
  <input type="button" value="Remover Seleccionados" onclick="removeRowFromTable('tblSample3');" />
</p>
<table border="1" id="tblSample3" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">
  <tr>
    <th colspan="5">Personal Necesario</th>
  </tr>
  <tr>
    <th>Item</th>
    <th>Cargo</th>
    <th>Horas</th>
    <th>Costo</th>
  
  </tr>
  <tr>
    <td>1</td>
    <td><input type="text" name="txtRow5"
     id="txtRow7" size="114"  /></td>
    <td><input name="txtRow5" type="text" id="txtRow8" size="10" /></td>
    <td><input name="txtRow5" type="text" id="txtRow9" size="10" />    </td>
    <td align="center" >      <div align="center">
      <input type="checkbox" name="checkbox3" id="checkbox3" />
    </div></td>
  </tr>
</table>
<p>&nbsp;</p>
<p>Costo Total del Trabajo :
 
  <input type="text" name="textfield" id="textfield" />
  
  
  <input type="submit" name="button" id="button" value="Guardar" />
  
</p>
<p>&nbsp;</p>
</form>

</table>
<%@include file="pie.jsp" %>